﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:viewModel="clr-namespace:SongTagger.UI.Wpf"
                    xmlns:gong="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop"
                    xmlns:songtagger="clr-namespace:SongTagger.Core;assembly=SongTagger.Core"
                    xmlns:metroControls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="ScrollViewer.xaml"/>
        <ResourceDictionary Source="SwitchBox.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <BooleanToVisibilityConverter x:Key="Bool2Visibility"/>
    <viewModel:BooleanInverter x:Key="BoolInverter"/>
    <viewModel:ColorToBrushConverter x:Key="ColorConvert"/>
    <viewModel:IsNullConverter x:Key="NullChecker"/>
    <viewModel:TimeSpanConverter x:Key="TimeSpanConvert"/>
    <viewModel:ByteArrayToBitmapConverter x:Key="ByteImageConverter"/>
    <viewModel:TaskbarItemInfoConverter x:Key="TaskBarStatusConverter"/>

    <Style TargetType="Image" x:Key="Shadow">
        <Setter Property="Effect">
            <Setter.Value>
                <DropShadowEffect Color="Black" Direction="320" ShadowDepth="5" Opacity="0.5"/>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="Button" x:Key="Back">
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Image Source="Images/back.png" Width="50" Height="50" Style="{StaticResource Shadow}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- #Region Entity -->
    <DataTemplate x:Key="artistEntityTemplate" DataType="{x:Type songtagger:Artist}">
        <Grid>
            <StackPanel>
                <TextBlock Text="{Binding Score}" 
                                                   HorizontalAlignment="Right"
                                                   FontSize="36"
                                                   Foreground="LightGray"
                                                   Opacity=".9"
                                                   FontWeight="ExtraLight"
                                                   Margin="0,-30,-10,15">
                    <TextBlock.RenderTransform>
                        <ScaleTransform ScaleX=".8" ScaleY="0.75"/>
                    </TextBlock.RenderTransform>
                </TextBlock>
                <Image Width="16" Height="16" HorizontalAlignment="Right" Opacity=".2">
                    <Image.Style>
                        <Style TargetType="Image">
                            <Setter Property="ToolTip" Value="{Binding Type}"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Type}" Value="Group">
                                    <Setter Property="Source"  Value="Images/artist.group.png"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Type}" Value="Person">
                                    <Setter Property="Source"  Value="Images/artist.person.png"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Image.Style>
                </Image>
            </StackPanel>
            <ItemsControl  ItemsSource="{Binding Tags}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Name}" FontSize="12" Foreground="Gray" Margin="1,0,1,0"/>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="releaseGroupEntityTemplate" DataType="{x:Type songtagger:ReleaseGroup}">
        <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*"/>
                <ColumnDefinition Width="1*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="1*"/>
                <RowDefinition Height="1*"/>
            </Grid.RowDefinitions>
            <Grid.Resources>
                <Style TargetType="TextBlock">
                    <Setter Property="Foreground" Value="DarkGray"/>
                    <Setter Property="FontSize" Value="14"/>
                </Style>
            </Grid.Resources>
            <TextBlock Text="{Binding PrimaryType}" HorizontalAlignment="Left" VerticalAlignment="Bottom"
                       Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"/>
            <TextBlock Text="{Binding FirstReleaseDate.Year}" 
                       HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,20,0"
                       Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2">
                <TextBlock.Resources>
                    <Style TargetType="TextBlock">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding FirstReleaseDate.Year}" Value="1">
                                <Setter Property="Opacity" Value="0"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </TextBlock.Resources>
            </TextBlock>
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="releaseEntityTemplate" DataType="{x:Type songtagger:Release}">

    </DataTemplate>

    <DataTemplate x:Key="entityTemplate" DataType="{x:Type viewModel:EntityViewModel}">
        <DataTemplate.Resources>
            <viewModel:EntityDataTemplateSelector x:Key="entitySelector"
                                                  ArtistDataTemplate="{StaticResource artistEntityTemplate}"
                                                  ReleaseGroupDataTemplate="{StaticResource releaseGroupEntityTemplate}"
                                                  ReleaseDataTemplate="{StaticResource releaseEntityTemplate}"
                                                  />
            <viewModel:StringPaddingConverter x:Key="PaddingConverter" MaxTextLengthIncPaddingString="18"/>
        </DataTemplate.Resources>
        <DockPanel LastChildFill="True" Width="180" Height="80">
            <Rectangle DockPanel.Dock="Left" Fill="{Binding EntityColor, Converter={StaticResource ColorConvert}}" Width="10" Margin="2,5,0,0"/>
            <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5,5,5,0">
                <TextBlock Text="{Binding Entity.Name, Converter={StaticResource PaddingConverter}}" 
                                               ToolTip="{Binding Entity.Name}"
                                               FontSize="18"/>
                <ContentControl Content="{Binding Entity}"
                                        ContentTemplateSelector="{StaticResource entitySelector}"/>
            </StackPanel>
        </DockPanel>

    </DataTemplate>

    <DataTemplate x:Key="songDataTemplate" DataType="{x:Type viewModel:Song}">
        <Grid Margin="5" AllowDrop="True"
                   gong:DragDrop.IsDropTarget="True"
                   gong:DragDrop.DropHandler="{Binding}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="45"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="5"/>
                <ColumnDefinition Width="25"/>
            </Grid.ColumnDefinitions>
            <Grid.Resources>
                <Style TargetType="Grid">
                    <Setter Property="Background" Value="LightGray"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding IsInitalized}" Value="true">
                            <Setter Property="Background" Value="WhiteSmoke"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Grid.Resources>
            <Label Content="{Binding Track.Position}" HorizontalAlignment="Right" Grid.Column="0" FontSize="18"
                   VerticalAlignment="Center" Foreground="Gray"
                   ContentStringFormat="{}#{0,-2}|"/>
            <Grid Grid.Column="1" Background="Transparent">
                <Label Content="{Binding Track.Name}" FontSize="22"/>
                <StackPanel HorizontalAlignment="Right" Orientation="Horizontal" VerticalAlignment="Center">
                    <Label Content="{Binding SourceFile.Name}" ToolTip="{Binding SourceFile.FullName}" ContentStringFormat="{}{0} //  " FontSize="12"/>
                    <Label Content="{Binding Track.Length, Converter={StaticResource TimeSpanConvert}}" FontSize="12"/>
                </StackPanel>
            </Grid>
            <Rectangle Fill="White" Grid.Column="2"/>
            <Button Command="{Binding EjectSourceFile}" Grid.Column="3"
                    Visibility="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled, Converter={StaticResource Bool2Visibility}}">
                <Button.ContentTemplate>
                    <DataTemplate>
                        <Image Source="Images/eject.png" Width="14"/>
                    </DataTemplate>
                </Button.ContentTemplate>
            </Button>
        </Grid>
    </DataTemplate>

    <!-- #EndRegion  -->

    <!-- #Region Workspace -->
    <DataTemplate x:Key="searchDataTemplate" DataType="{x:Type viewModel:SearchViewmodel}">
        <Grid>
            <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,150,0">
                <StackPanel.Resources>
                    <Style TargetType="StackPanel">
                        <Style.Triggers>
                            <EventTrigger RoutedEvent="Loaded">
                                <EventTrigger.Actions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="0:0:0.8" From="0.0" To="1.0"  />
                                        </Storyboard>
                                    </BeginStoryboard>
                                </EventTrigger.Actions>
                            </EventTrigger>
                        </Style.Triggers>
                    </Style>
                </StackPanel.Resources>
                <TextBlock Text="{Binding Header}" FontSize="48"/>
                <Grid>
                    <TextBox Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" BorderBrush="DarkGray" BorderThickness="1"
                                         IsEnabled="{Binding IsQueryRunning, Converter={StaticResource BoolInverter}}"
                                         FontSize="22" TextAlignment="Center" TextWrapping="Wrap" Padding="0,0,32,0">
                        <TextBox.InputBindings>
                            <KeyBinding Key="Enter" Command="{Binding Search}"/>
                        </TextBox.InputBindings>
                    </TextBox>
                    <Button HorizontalAlignment="Right"
                                    Command="{Binding Search}"
                                    IsEnabled="{Binding IsQueryRunning, Converter={StaticResource BoolInverter}}">
                        <Button.Content>
                            <Image Source="Images/search.png" Width="32" Height="32"/>
                        </Button.Content>
                    </Button>
                </Grid>
                <metroControls:ProgressRing IsActive="{Binding IsQueryRunning}" Foreground="Gray"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom">
                <StackPanel.Resources>
                    <Style TargetType="Label">
                        <Setter Property="FontSize" Value="12"/>
                        <Setter Property="Foreground" Value="Gray"/>
                        <Setter Property="Margin" Value="0,0,2,0"/>
                    </Style>
                </StackPanel.Resources>
                <Label Content="developed by balazs4"/>
                <Label>
                    <Label.Content>
                        <Hyperlink Command="{Binding OpenLink}"
                                   CommandParameter="http://songtagger.codeplex.com/">
                            songtagger
                        </Hyperlink>
                    </Label.Content>
                </Label>
                <Label Content="GPLv2"/>
            </StackPanel>
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="marketDataTemplate" DataType="{x:Type viewModel:MarketViewModel}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="2*"/>
                <RowDefinition Height="9*"/>
            </Grid.RowDefinitions>
            <Grid Grid.Row="0" Name="header">
                <StackPanel Grid.Row="0" Margin="0,0,20,0" HorizontalAlignment="Right" VerticalAlignment="Center">
                    <TextBlock Text="{Binding Header}" FontSize="48" />
                    <Grid Width="150" HorizontalAlignment="Right" Opacity=".5" Margin="0,5,0,0">
                        <TextBlock Text="Filter..." FontSize="12" Margin="10,1,0,0" TextAlignment="Left" 
                                                   FontStyle="Italic" Foreground="Gray"
                                                   Visibility="{Binding ElementName=filter, Path=Text.IsEmpty, 
                                                                Converter={StaticResource Bool2Visibility}}"/>
                        <TextBox Text="{Binding FilterText, UpdateSourceTrigger=PropertyChanged}" Name="filter"
                                             Background="Transparent" BorderThickness="1" BorderBrush="Gray" FontSize="12"/>
                    </Grid>
                </StackPanel>
            </Grid>
            <Grid Grid.Row="1" Name="content">
                <ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
                         ScrollViewer.VerticalScrollBarVisibility="Visible"
                                     BorderThickness="0"
                                     ItemsSource="{Binding EntitiesView}"
                                     ItemTemplate="{StaticResource entityTemplate}"
                                     gong:DragDrop.IsDragSource="True">
                    <ListBox.Resources>
                        <Style TargetType="ListBoxItem">
                            <Setter Property="HorizontalAlignment" Value="Stretch" />
                            <Setter Property="Background" Value="Transparent" />
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                        <Grid>
                                            <Border Background="{TemplateBinding Background}" />
                                            <Border Background="#BEFFFFFF" Margin="1,1" />
                                            <ContentPresenter Margin="8,5" />
                                        </Grid>
                                        <ControlTemplate.Triggers>
                                            <MultiTrigger>
                                                <MultiTrigger.Conditions>
                                                    <Condition Property="IsMouseOver" Value="True" />
                                                    <Condition Property="IsSelected" Value="False"/>
                                                </MultiTrigger.Conditions>
                                                <Setter Property="Background" Value="LightGray" />
                                            </MultiTrigger>
                                            <Trigger Property="IsSelected" Value="True">
                                                <Setter Property="Background" Value="LightSteelBlue"/>
                                            </Trigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                            <Style.Triggers>
                                <EventTrigger RoutedEvent="Loaded">
                                    <EventTrigger.Actions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation Duration="0:0:0.4"
                                                                         Storyboard.TargetProperty="Opacity"
                                                                         From="0.6"
                                                                         To="1.0"  />
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </EventTrigger.Actions>
                                </EventTrigger>
                            </Style.Triggers>
                        </Style>
                        <Style TargetType="ListBox">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Items.Count}" 
                                                     Value="0">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate>
                                                <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center"
                                                                    Opacity=".5">
                                                    <Image Source="Images/noresult.png" Height="48" Width="48"/>
                                                    <TextBlock FontSize="48">No result</TextBlock>
                                                </StackPanel>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </DataTrigger>
                            </Style.Triggers>
                            <Setter Property="ItemsPanel">
                                <Setter.Value>
                                    <ItemsPanelTemplate>
                                        <WrapPanel Orientation="Horizontal"/>
                                    </ItemsPanelTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </ListBox.Resources>
                </ListBox>
            </Grid>
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="virtualReleaseTemplate" DataType="{x:Type viewModel:VirtualReleaseViewModel}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="150"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid Grid.Row="0" Name="header" Background="Transparent">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="110"/>
                        <ColumnDefinition Width="*" MinWidth="200"/>
                        <ColumnDefinition Width="96"/>
                    </Grid.ColumnDefinitions>
                    <Grid Grid.Column="0" VerticalAlignment="Center">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="110"/>
                            <RowDefinition MaxHeight="48" Height="18"/>
                        </Grid.RowDefinitions>
                        <ListBox ItemsSource="{Binding Covers, IsAsync=True}" Name="CoverList" Grid.Row="1" HorizontalAlignment="Center"
                             ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                             ScrollViewer.VerticalScrollBarVisibility="Disabled"
                             BorderThickness="0" SelectedIndex="0"
                            SelectedItem="{Binding SelectedCover}" SelectionMode="Single">
                            <ListBox.Resources>
                                <Style TargetType="ListBox">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Items.Count}" Value="0">
                                            <Setter Property="Template">
                                                <Setter.Value>
                                                    <ControlTemplate>
                                                        <StackPanel VerticalAlignment="Top" HorizontalAlignment="Center" Opacity=".8" Margin="0,-55,0,0">
                                                            <metroControls:MetroProgressBar EllipseDiameter="5" EllipseOffset="1" IsIndeterminate="True" Width="105" Foreground="Gray"/>
                                                        </StackPanel>
                                                    </ControlTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </ListBox.Resources>
                            <ListBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <WrapPanel Orientation="Horizontal"/>
                                </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Ellipse Width="4" Height="4" Fill="Gray" Margin="2"/>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                        <Grid Margin="0" VerticalAlignment="Bottom">
                            <viewModel:DynamicImage Stretch="UniformToFill" MaxWidth="110" MaxHeight="110" VerticalAlignment="Center" HorizontalAlignment="Left" Grid.Row="0">
                                <viewModel:DynamicImage.Resources>
                                    <BitmapImage x:Key="NoCover" UriSource="Images/disc.png" />
                                </viewModel:DynamicImage.Resources>
                                <viewModel:DynamicImage.Style>
                                    <Style TargetType="viewModel:DynamicImage">
                                        <Style.Triggers>
                                            <EventTrigger RoutedEvent="viewModel:DynamicImage.SourceChanged">
                                                <EventTrigger.Actions>
                                                    <BeginStoryboard>
                                                        <Storyboard>
                                                            <DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="0:0:0.3" From="0.5" To="1.0"/>
                                                        </Storyboard>
                                                    </BeginStoryboard>
                                                </EventTrigger.Actions>
                                            </EventTrigger>
                                            <Trigger Property="IsVisible" Value="True">
                                                <Setter Property="ToolTip">
                                                    <Setter.Value>
                                                        <Image Source="{Binding SelectedCover.Data, Converter={StaticResource ByteImageConverter}}"/>
                                                    </Setter.Value>
                                                </Setter>
                                            </Trigger>
                                        </Style.Triggers>
                                    </Style>
                                </viewModel:DynamicImage.Style>
                                <viewModel:DynamicImage.Source>
                                    <Binding Path="SelectedCover.Data" Converter="{StaticResource ByteImageConverter}" TargetNullValue="{StaticResource NoCover}"/>
                                </viewModel:DynamicImage.Source>
                            </viewModel:DynamicImage>

                            <Button ToolTip="Add custom covertart link from clipboard" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="customCover"
                                    Command="{Binding AddCoverArtLink}" Visibility="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled, Converter={StaticResource Bool2Visibility}}">
                                <Button.Template>
                                    <ControlTemplate>
                                        <Grid>
                                            <Grid.Resources>
                                                <Style x:Key="AnimationImage" TargetType="{x:Type Image}" BasedOn="{StaticResource Shadow}">
                                                    <Setter Property="RenderTransform">
                                                        <Setter.Value>
                                                            <RotateTransform Angle="0" CenterX="16" CenterY="16" />
                                                        </Setter.Value>
                                                    </Setter>
                                                    <Style.Triggers>
                                                        <Trigger Property="IsVisible" Value="true">
                                                            <Trigger.EnterActions>
                                                                <BeginStoryboard>
                                                                    <Storyboard>
                                                                        <DoubleAnimation Storyboard.TargetProperty="RenderTransform.Angle" 
                                                                                         To="-60" Duration="0:0:0.2" AutoReverse="True" RepeatBehavior="2x" />
                                                                    </Storyboard>
                                                                </BeginStoryboard>
                                                            </Trigger.EnterActions>
                                                        </Trigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </Grid.Resources>
                                            <Border Background="Black" Opacity=".75" Padding="15"/>
                                            <Ellipse Fill="WhiteSmoke" Height="64" Width="64" Margin="15" Opacity=".95"/>
                                            <Image Source="Images/add.png" Width="32" Opacity="1.0" Style="{StaticResource AnimationImage}"/>
                                        </Grid>
                                    </ControlTemplate>
                                </Button.Template>
                            </Button>
                            <Button ToolTip="No thanks, no custom coverart" Command="{Binding CancelCustomCovertArt}" 
                                    HorizontalAlignment="Right" VerticalAlignment="Top" Margin="5"
                                    Visibility="{Binding ElementName=customCover, Path=Visibility}">
                                <Button.Template>
                                    <ControlTemplate>
                                        <Canvas Name="canvas" Height="0" Width="10">
                                            <Path Stroke="LightCoral" StrokeThickness="4">
                                                <Path.Data>
                                                    <PathGeometry>
                                                        <PathGeometry.Figures>
                                                            <PathFigure StartPoint="0,0">
                                                                <LineSegment Point="10,10"/>
                                                            </PathFigure>
                                                            <PathFigure StartPoint="0,10">
                                                                <LineSegment Point="10,0"/>
                                                            </PathFigure>
                                                        </PathGeometry.Figures>
                                                    </PathGeometry>
                                                </Path.Data>
                                            </Path>
                                        </Canvas>
                                    </ControlTemplate>
                                </Button.Template>
                            </Button>
                        </Grid>
                    </Grid>
                    <StackPanel Grid.Column="1" Margin="10,0,10,0" HorizontalAlignment="Left" VerticalAlignment="Center" MinWidth="200">
                        <TextBlock Text="{Binding Artist.Name}" FontSize="20"/>
                        <TextBlock Text="{Binding ReleaseGroup.Name}" FontSize="24" FontWeight="Bold"/>
                        <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0,5,0,0">
                            <TextBlock Text="{Binding ReleaseGroup.PrimaryType}" Foreground="DarkGray"/>
                            <TextBlock Text="{Binding ReleaseGroup.FirstReleaseDate.Year}"  HorizontalAlignment="Right">
                                <TextBlock.Resources>
                                    <Style TargetType="TextBlock">
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding ReleaseGroup.FirstReleaseDate.Year}" Value="1">
                                                <Setter Property="Opacity" Value="0"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </TextBlock.Resources>
                            </TextBlock>
                        </Grid>
                    </StackPanel>
                    <Grid Grid.Column="2" Margin="0,0,50,0">
                        <Button ToolTip="Save" Command="{Binding Save}"
                            Visibility="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled, Converter={StaticResource Bool2Visibility}}">
                            <Button.Template>
                                <ControlTemplate>
                                    <Image Source="Images/save.png" Opacity=".9"/>
                                </ControlTemplate>
                            </Button.Template>
                        </Button>
                    </Grid>
                    <Grid Grid.Column="1" Name="folderDragAndDrop" >
                        <Rectangle Stroke="Gray" StrokeDashArray="10 10" Opacity=".8" Margin="1"
                                   Visibility="{Binding IsFolderDragNDropActive, Converter={StaticResource Bool2Visibility}}"/>
                        <Rectangle Fill="Transparent"  AllowDrop="True" gong:DragDrop.DropHandler="{Binding}" gong:DragDrop.IsDropTarget="True"/>
                    </Grid>
                </Grid>
            </Grid>
            <Grid Grid.Row="1" Name="content"  Background="Transparent">
                <ScrollViewer>
                    <ItemsControl ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                         ScrollViewer.VerticalScrollBarVisibility="Visible"
                         HorizontalContentAlignment="Stretch"
                         HorizontalAlignment="Stretch"
                         Background="Transparent"
                         BorderThickness="0"
                         ItemsSource="{Binding Songs}"
                         ItemTemplate="{StaticResource songDataTemplate}">
                    </ItemsControl>
                </ScrollViewer>
            </Grid>
        </Grid>
    </DataTemplate>

    <!-- #EndRegion -->

    <!-- #Region Cart  -->
    <DataTemplate x:Key="nonVisibleTemplate"  DataType="{x:Type viewModel:DummyCartViewModel}">
        <Button Grid.Row="2" Height="32" Width="32" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,0"
                Command="{Binding OpenSettings}" ToolTip="Settings...">
            <Button.Template>
                <ControlTemplate>
                    <Image Source="Images/settings.png" Height="32" Opacity=".7" Style="{StaticResource Shadow}"/>
                </ControlTemplate>
            </Button.Template>
        </Button>
    </DataTemplate>
    <DataTemplate x:Key="defaultCartTemplate" DataType="{x:Type viewModel:CartViewModel}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="100"/>
            </Grid.RowDefinitions>
            <ItemsControl Grid.Row="0" ItemsSource="{Binding Collection}" Background="Transparent" 
                          HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,25">
                <ItemsControl.ItemTemplate>
                    <DataTemplate DataType="{x:Type viewModel:EntityViewModel}">
                        <DockPanel LastChildFill="True" Height="40" Margin="0">
                            <Rectangle DockPanel.Dock="Left" 
                                       Fill="{Binding EntityColor, Converter={StaticResource ColorConvert}}" 
                                       Width="10" Margin="2,5,0,0"/>
                            <Grid VerticalAlignment="Center" Margin="2,0,0,0">
                                <Image Source="{Binding EntityImage}" Width="48" Stretch="None"
                                   Opacity=".25" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
                                <TextBlock Text="{Binding Entity.Name}" 
                                       ToolTip="{Binding Entity.Name}"
                                       FontSize="12"/>
                            </Grid>
                        </DockPanel>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
                <ItemsControl.Style>
                    <Style TargetType="ItemsControl">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Collection.Count}" Value="0">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate>
                                            <Grid Background="Transparent">
                                                <Rectangle Stroke="Gray" StrokeDashArray="10 10" Opacity=".8"/>
                                                <Image Source="Images/cart.png" Width="64" Opacity=".4" Style="{StaticResource Shadow}"/>
                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </ItemsControl.Style>
            </ItemsControl>
            <Button Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,0"
                        Command="{Binding Remove}"
                        ToolTip="Previous">
                <Button.Template>
                    <ControlTemplate>
                        <StackPanel>
                            <Image Source="Images/back.png" Height="32" Opacity=".7" Style="{StaticResource Shadow}"/>
                        </StackPanel>
                    </ControlTemplate>
                </Button.Template>
            </Button>
        </Grid>

    </DataTemplate>
    <!-- #EndRegion  -->

    <!-- #Region Settings  -->
    <DataTemplate x:Key="pathSettingTempalte" DataType="{x:Type viewModel:PathSettingViewModel}">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="48"/>
            </Grid.ColumnDefinitions>
            <TextBox Text="{Binding FullPath, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True}">
                <TextBox.Style>
                    <Style TargetType="{x:Type TextBox}">
                        <Style.Triggers>
                            <Trigger Property="Validation.HasError" Value="true">
                                <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </TextBox.Style>
            </TextBox>
            <Button Content="..." Grid.Column="1" Margin="8,0"  Command="{Binding Browse}"/>
        </Grid>
    </DataTemplate>
    <DataTemplate x:Key="switchSettingTempalte" DataType="{x:Type viewModel:SwitchSettingViewModel}">
        <Grid HorizontalAlignment="Left">
            <CheckBox IsChecked="{Binding Enabled}" Style="{StaticResource SwitchBox}" />
        </Grid>
    </DataTemplate>
    <!-- #EndRegion  -->



</ResourceDictionary>